org.eclipse.vtp.framework.interactions.voice.vxml
Class EventHandler

java.lang.Object
  extended by org.eclipse.vtp.framework.interactions.core.support.Widget
      extended by org.eclipse.vtp.framework.interactions.voice.vxml.EventHandler
All Implemented Interfaces:
VXMLConstants
Direct Known Subclasses:
Catch, NoInput, NoMatch

public abstract class EventHandler
extends Widget
implements VXMLConstants

The EventHandler class is the base class for the family of VXML elements that process events and errors that are generated during execution of a VXML document. Each instance contains a list of actions for the interpreter to perform if the event handler receives an event. These actions are written to the VXML document in the order they were added. There are two optional methods to govern whether the event is received by the event handler instance. A conditional expression can be specified that must evaluate to true at the time the event is generated for the event handler to be notified of the event. Also, an event handler can declare that it only needs to be notified if it is the nth occurrence of the event by setting the count field. Each of these options can be employed separately or together.

Version:
2.0
Author:
Trip Gilman, Lonnie Pryor

Field Summary
 
Fields inherited from interface org.eclipse.vtp.framework.interactions.voice.vxml.VXMLConstants
EMPTY, FILE_EXT_GSL, FILLED_MODE_ALL, FILLED_MODE_ANY, GRAMMAR_MODE_DTMF, GRAMMAR_MODE_VOICE, METHOD_GET, METHOD_POST, MIME_TYPE_GSL, MIME_TYPE_SRGS, NAME_APPLICATION, NAME_ASSIGN, NAME_AUDIO, NAME_BARGEIN, NAME_BEEP, NAME_BLOCK, NAME_BRIDGE, NAME_CATCH, NAME_CHOICE, NAME_COMPLETETIMEOUT, NAME_COND, NAME_CONFIDENCELEVEL, NAME_COUNT, NAME_DEST, NAME_DISCONNECT, NAME_DTMF, NAME_DTMFTERM, NAME_ELSE, NAME_ELSEIF, NAME_ENCTYPE, NAME_ENUMERATE, NAME_ERROR, NAME_EVENT, NAME_EVENTEXPR, NAME_EXIT, NAME_EXPR, NAME_FIELD, NAME_FILLED, NAME_FINALSILENCE, NAME_FORM, NAME_GOTO, NAME_GRAMMAR, NAME_ID, NAME_IF, NAME_INCOMPLETETIMEOUT, NAME_INPUTMODES, NAME_INTERDIGITTIMEOUT, NAME_ITEM, NAME_MAXNBEST, NAME_MAXSPEECHTIMEOUT, NAME_MAXTIME, NAME_MENU, NAME_METHOD, NAME_MODE, NAME_NAME, NAME_NAMELIST, NAME_NEXT, NAME_NOINPUT, NAME_NOMATCH, NAME_ONE_OF, NAME_OPTION, NAME_PARAM, NAME_PROMPT, NAME_PROPERTY, NAME_RECORD, NAME_REPEAT, NAME_REPROMPT, NAME_RETURN, NAME_ROOT, NAME_RULE, NAME_SCOPE, NAME_SCRIPT, NAME_SENSITIVITY, NAME_SPEEDVSACCURACY, NAME_SRC, NAME_SUBDIALOG, NAME_SUBMIT, NAME_TERMCHAR, NAME_TERMTIMEOUT, NAME_THROW, NAME_TIMEOUT, NAME_TRANSFER, NAME_TYPE, NAME_VALUE, NAME_VAR, NAME_VERSION, NAME_VXML, NAMESPACE_URI_VXML, QNAME_XML_LANG, SCOPE_DIALOG, SCOPE_DOCUMENT, TYPE_CDATA, VERSION_2_0
 
Constructor Summary
protected EventHandler()
          Creates a new instance of EventHandler which does not employ a conditional expression or require a specific number of occurrences to receive an event.
protected EventHandler(int count)
          Creates a new instance of EventHandler that requires a specific number of occurrences of an event to receive it.
protected EventHandler(int count, java.lang.String condition)
          Creates a new instance of EventHandler with a conditional expression that must evaluate to true for the event handler to receive an event.
protected EventHandler(java.lang.String condition)
          Creates a new instance of EventHandler with a conditional expression that must evaluate to true for the event handler to receive an event.
 
Method Summary
 void addAction(Action action)
          Adds the action to the list of actions to be performed by the interpreter if this event handler receives an event.
 void addIfClause(If ifClause)
          Inserts a conditional set of actions into the list of actions to be performed by the interpreter if this event handler receives an event.
 Widget[] getActionsAndIfClauses()
          Returns the list of actions and conditionals in this event handler.
 java.lang.String getCondition()
          Returns the conditional expression that must evaluate to true before this event handler can receive an event.
 int getCount()
          Returns the number of occurrences of an event that will trigger this event handler.
 void removeAction(Action action)
          Removes the action from the list of actions to be performed by the interpreter if this event handler receives an event.
 void removeIfClause(If ifClause)
          Removes the conditional set of actions from the list of actions to be performed by the interpreter if this event handler receives an event.
 void setCondition(java.lang.String condition)
          Sets the conditional expression that must evaluate to true for the event handler to accept an event.
 void setCount(int count)
          Sets the number of occurrences of the event that this event handler will accept.
protected  void writeActionsAndIfClauses(org.xml.sax.ContentHandler outputHandler)
          Write the actions and if clauses of this handler to the specified content handler.
protected  void writeAttributes(org.xml.sax.helpers.AttributesImpl attributes)
          Write the attribute members of this handler to the supplied set.
 
Methods inherited from class org.eclipse.vtp.framework.interactions.core.support.Widget
toString, writeAttribute, writeChildren, writeChildren, writeWidget, writeWidget, writeWidget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventHandler

protected EventHandler()
Creates a new instance of EventHandler which does not employ a conditional expression or require a specific number of occurrences to receive an event.


EventHandler

protected EventHandler(int count)
Creates a new instance of EventHandler that requires a specific number of occurrences of an event to receive it. It does not employ a conditional expression that must be evaluated before receiving an event.

Parameters:
count - The number of occurrences of an event for this event handler to receive it.

EventHandler

protected EventHandler(java.lang.String condition)
                throws java.lang.IllegalArgumentException
Creates a new instance of EventHandler with a conditional expression that must evaluate to true for the event handler to receive an event. It does not require a specific number of occurrences to receive an event.

Parameters:
condition - Expression that must evaluate to true for the event handler to receive the event
Throws:
java.lang.IllegalArgumentException - If the supplied condition is empty.

EventHandler

protected EventHandler(int count,
                       java.lang.String condition)
                throws java.lang.IllegalArgumentException
Creates a new instance of EventHandler with a conditional expression that must evaluate to true for the event handler to receive an event. It also requires a specific number of occurrences of the event to receive it.

Parameters:
count - The number of occurrences of an event for this event handler to receive it.
condition - Expression that must evaluate to true for the event handler to receive the event.
Throws:
java.lang.IllegalArgumentException - If the supplied condition is empty.
Method Detail

getCount

public int getCount()
Returns the number of occurrences of an event that will trigger this event handler.

Returns:
The number of occurrences.

getCondition

public java.lang.String getCondition()
Returns the conditional expression that must evaluate to true before this event handler can receive an event.

Returns:
The conditional expression.

getActionsAndIfClauses

public Widget[] getActionsAndIfClauses()
Returns the list of actions and conditionals in this event handler.

Returns:
The list of actions and conditionals in this event handler.

setCount

public void setCount(int count)
Sets the number of occurrences of the event that this event handler will accept.

Parameters:
count - The new number of occurrences.

setCondition

public void setCondition(java.lang.String condition)
                  throws java.lang.IllegalArgumentException
Sets the conditional expression that must evaluate to true for the event handler to accept an event.

Parameters:
condition - The conditional expression.
Throws:
java.lang.IllegalArgumentException - If the supplied condition is empty.

addAction

public void addAction(Action action)
               throws java.lang.NullPointerException
Adds the action to the list of actions to be performed by the interpreter if this event handler receives an event. The list of actions are written to the VXML document in the order they were added.

Parameters:
action - The action to add.
Throws:
java.lang.NullPointerException - If the supplied action is null.

removeAction

public void removeAction(Action action)
                  throws java.lang.NullPointerException
Removes the action from the list of actions to be performed by the interpreter if this event handler receives an event.

Parameters:
action - The action to remove.
Throws:
java.lang.NullPointerException - If the supplied action is null.

addIfClause

public void addIfClause(If ifClause)
                 throws java.lang.NullPointerException
Inserts a conditional set of actions into the list of actions to be performed by the interpreter if this event handler receives an event.

Parameters:
ifClause - The conditional set of actions to add.
Throws:
java.lang.NullPointerException - If the supplied conditional is null.

removeIfClause

public void removeIfClause(If ifClause)
                    throws java.lang.NullPointerException
Removes the conditional set of actions from the list of actions to be performed by the interpreter if this event handler receives an event.

Parameters:
ifClause - The conditional set of actions to remove.
Throws:
java.lang.NullPointerException - If the supplied conditional is null.

writeAttributes

protected void writeAttributes(org.xml.sax.helpers.AttributesImpl attributes)
Write the attribute members of this handler to the supplied set.

Parameters:
attributes - The attribute set to write to.
Throws:
java.lang.NullPointerException - If the supplied attribute set is null.

writeActionsAndIfClauses

protected void writeActionsAndIfClauses(org.xml.sax.ContentHandler outputHandler)
                                 throws java.lang.NullPointerException,
                                        org.xml.sax.SAXException
Write the actions and if clauses of this handler to the specified content handler.

Parameters:
outputHandler - The content handler to write to.
Throws:
java.lang.NullPointerException - If the supplied content handler is null.
org.xml.sax.SAXException - If the writing of one of the actions or if clauses fails.